<!DOCTYPE html>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 85167
  Date: 2017/12/10
  Time: 11:00
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>字典类型管理</title>
    <c:import url="/WEB-INF/page/header.jsp"/>
</head>
<body>
<h4 class="m-t"></h4>
<div class="col-sm-12">
    <!-- Example Toolbar -->
    <div class="example-wrap">
        <div class="panel panel-default">
            <div class="panel-heading"><b>装机利润信息管理</b></div>
            <div class="panel-body">
                <form id="formSearch" class="form-inline">
                    <div class="form-group">
                        <span>经销商ID：</span>
                        <input type="text" class="form-control" id="distributorId">
                    </div>
                </form>
            </div>
        </div>
        <div class="example">
            <div class="hidden-xs" id="dataTableToolbar" role="group">
                <div class="pull-left" style="margin-bottom: 8px;">
                    <button type="button" class="btn btn-white btn-sm" onclick="add()">
                        <i class="fa fa-plus">&nbsp;新增</i>
                    </button>
                    <button type="button" class="btn btn-white btn-sm"
                            onclick="javascript: $('#dataTable').bootstrapTable('refresh');">
                        <i class="glyphicon glyphicon-repeat">&nbsp;刷新</i>
                    </button>
                </div>
                <div class="pull-right">
                    <button type="button" id="btn_query"
                            class="btn btn-primary btn-rounded btn-outline btn-sm "
                            onclick="javascript: $('#dataTable').bootstrapTable('refresh');">
                        <i class="fa fa-search"></i>查询
                    </button>
                </div>
            </div>
            <table id="dataTable">
            </table>
        </div>
    </div>
    <!-- End Example Toolbar -->
</div>
<c:import url="/WEB-INF/page/footer.jsp"/>
<script type="text/javascript">
    // Example Bootstrap Table Toolbar
    // -------------------------------
    (function () {
        $('#dataTable').bootstrapTable({
            url: base + "/admin/biz/distributionAccounts/list",
            method: "post",
            queryParams: function (params) {
                var temp = {   //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                    limit: params.limit,   //页面大小
                    offset: params.offset,  //页码
                    distributorId: $("#distributorId").val(),
                };
                return temp;
            },
            toolbar: '#dataTableToolbar',
            pagination: true,
            sidePagination: "server",
            columns: [{
                checkbox: true
            }, {
                field: 'distributorId',
                title: '经销商ID'
            }, {
                field: 'startTime',
                title: '开始时间'
            }, {
                field: 'endTime',
                title: '结束时间'
            }, {
                field: 'amount',
                title: '结算金额'
            }, {
                field: 'createTime',
                title: '创建时间'
            }, {
                field: 'status',
                title: '状态',
                formatter: function (value, row, index) {
                    if (value == 1) {
                        return "已结算";
                    } else {
                        return "未结算";
                    }
                }
            }, {
                formatter: function (value, row, index) {
                    if (row.status == 1) {
                        return "";
                    }
                    return [
                        '<a class="btn btn-success  btn-xs" href="javascript:accounts(' + row.id + ')">' +
                        '<i class="glyphicon glyphicon-pencil"></i>结算' +
                        '</a>&nbsp;'
                    ].join('');
                },
                title: '操作'
            }]
        });
    })();

    function accounts(id) {
        swal({
            title: "您确定要处理结算信息吗",
            text: "结算后将无法恢复，请谨慎操作！",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "结算",
            cancelButtonText: "取消",
            closeOnConfirm: false
        }, function () {
            doChgStatus(base + "/admin/biz/distributionAccounts/accounts?id=" + id);
        });
    }

    function add() {
        openDialog("新增结算信息", base + "/admin/biz/distributionAccounts/add/0");
    }

</script>
</body>
</html>
